/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.htmlparser.nodes.*;
import org.htmlparser.*;
import org.htmlparser.filters.AndFilter;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.filters.TagNameFilter;
import org.htmlparser.tags.*;
import org.htmlparser.util.*;

/**
 *
 * @author alvar
 */
public class mytest1 {

    public static void main(String args[]) {
        try {
            String url2 = "http://www.uwants.com/archiver/";
            String url = "http://www.discuss.com.hk/archiver/";
            Parser p;
            NodeList list;
            p = new Parser(url);
//            list = p.parse(new NodeClassFilter(BulletList.class));
            list = p.parse(new TagNameFilter("ul"));
            process(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    static int i = 0;

    static void process(NodeList list) throws Exception {
        BufferedWriter w = new BufferedWriter(new FileWriter("C:\\out.txt"));
        NodeIterator iterator = list.elements();
//        System.out.println(list.elementAt(0).toHtml()+"\n\n");
//         while (iterator.hasMoreNodes()){
//             Node node = iterator.nextNode();
//             if ("archiver_forumlist".equalsIgnoreCase(((Tag) node).getAttribute("class")))
//                 System.out.println(node.toHtml(true)+"\n\n");             
//         }
        while (iterator.hasMoreNodes()){
             Node node = iterator.nextNode();
             w.write(node.toHtml(true));
             System.out.println(node.toHtml()+"\n\n");
         }
        w.flush();
        w.close();
    }
}